<?php
    require('db_connection.php');
   
    
    $query1 = "SELECT MAX(materialID) FROM tblcollection";
    $result1 = mysql_query($query1);
    while($row=mysql_fetch_array($result1))
    {
      $bookcount  = $row['MAX(materialID)'];
      
    }
    if($bookcount>4)
    {
      $start = $bookcount-4;
    }
    else
    {
      $start = 0;
    }
?>
<table width='100%' height='100%' valign='top'>
    <tr>
        <td class='tableheader'>New Arrivals</td></tr>
        <tr>
        <?php
            
            for($ctr=$start; $ctr<=$bookcount; $ctr++)
            {
                $query = "SELECT * FROM tblcollection WHERE materialID=$ctr";
                $result = mysql_query($query);
                while($row=mysql_fetch_array($result))
                {
                  echo"<tr><td class='news'><a href='detail.php?materialID=$ctr'>";
                  echo $row[4];
                  echo"</a> <i> by $row[5] </i></td></tr>";
                  echo"<tr><td > </td></tr>";


                }
            }
        ?>

    </tr>

</table>
